package apps.apeTest
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	import org.cove.ape.APEngine;
	import org.cove.ape.CircleParticle;
	import org.cove.ape.Group;
	import org.cove.ape.RectangleParticle;
	import org.cove.ape.SpringConstraint;
	import org.cove.ape.Vector;
	import org.cove.ape.WheelParticle;
	
	public class ApeTest extends Sprite
	{
		public function ApeTest()
		{
			super();
			APEngine.init(0.25);
			APEngine.container = this;
			APEngine.addMasslessForce(new Vector(0,2));
			var defaultGroup:Group = new Group();
			defaultGroup.collideInternal = true;			
			var cp:CircleParticle = new CircleParticle(250,10,5);
			defaultGroup.addParticle(cp);         	
			var wp:WheelParticle = new WheelParticle(280,10,5,false,1,0.3,0.1,1);
			defaultGroup.addParticle(wp);
			var rrp:RectangleParticle = new RectangleParticle(250,10,80,10,6,false,2);
			defaultGroup.addParticle(rrp);
			var rp:RectangleParticle = new RectangleParticle(250,300,200,10,-0.52,true);
			defaultGroup.addParticle(rp);      
			var rp2:RectangleParticle = new RectangleParticle(150,200,200,10,0.52,true);
			defaultGroup.addParticle(rp2);        
			var rp3:RectangleParticle = new RectangleParticle(250,50,200,10,-0.52,true);
			defaultGroup.addParticle(rp3);
			var wa: WheelParticle = new WheelParticle(160,20,10,false,2);
			defaultGroup.addParticle(wa);		
			var wb: WheelParticle = new WheelParticle(250,20,30,false,2)
			defaultGroup.addParticle(wb);		
			var wc:SpringConstraint = new SpringConstraint(wa, wb, 1, true,10,1.5);
			defaultGroup.addConstraint(wc);       	
			APEngine.addGroup(defaultGroup);
			addEventListener(Event.ENTER_FRAME,handleRun);
		}
		private function handleRun(e:Event):void
		{
			APEngine.step();
			APEngine.paint();
		}
	}
}